package com.test.nnooolwdeaer.activity_fragment_wooden.fragment_wooden;

import static android.view.View.VISIBLE;

import android.annotation.SuppressLint;
import android.os.Bundle;

import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.test.nnooolwdeaer.R;
import com.test.nnooolwdeaer.activity_fragment_wooden.base_wooden.BaseLoanFragment_wooden;
import com.test.nnooolwdeaer.bean_wooden.config_info_wooden.AppShowInfo_wooden;
import com.test.nnooolwdeaer.bean_wooden.process_wooden.ProcessInfo_wooden;
import com.test.nnooolwdeaer.constant_wooden.Constant_wooden;
import com.test.nnooolwdeaer.dialog_wooden.DropDialog_wooden;
import com.test.nnooolwdeaer.util_wooden.http_wooden.HttpManager_wooden;


public class LoanFailFragment_wooden extends BaseLoanFragment_wooden {

    private View dropView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_loan_fail_wooden, container, false);
        init_wooden(view);
        return view;
    }

    @SuppressLint("SetTextI18n")
    private void init_wooden(View view) {

        TextView textTv = view.findViewById(R.id.fragment_loan_fail_tv_text);

        view.findViewById(R.id.fragment_loan_fail_btn_refresh_status).setOnClickListener(v -> HttpManager_wooden.getInstance_wooden().requestUserProcess_wooden());
        String days = ProcessInfo_wooden.getInstance_wooden().getDeniedBetweenDay_wooden();
        if (TextUtils.isEmpty(days)) days = AppShowInfo_wooden.getInstance().getRejectPeriod();
        textTv.setText(getString(R.string.fragment_loan_fail_text_1) + days + getString(R.string.fragment_loan_fail_text_2));

        dropView = view.findViewById(R.id.fragment_loan_fail_view_delete_data);

    }

    public void onDropConfigResponse(boolean showDropBtn) {
        try {
            if (showDropBtn) {
                dropView.setVisibility(VISIBLE);
                dropView.setOnClickListener(view -> {
                    new DropDialog_wooden(requireContext()).show();
                });
            }
        } catch (Exception e) {
            if (Constant_wooden.Debug) e.printStackTrace();
        }
    }

}